package com.ruoyi.shop.modules.service.impl;

import com.ruoyi.shop.modules.mapper.CKMapper;
import com.ruoyi.shop.modules.mapper.UserDataMapper;
import com.ruoyi.shop.modules.service.DataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: JinChen Zhu
 * @CreateTime: 2024-07-03  12:41
 */
@Service
public class DataServiceImpl implements DataService {
    @Autowired
    private UserDataMapper userDataMapper;
    @Autowired
    private CKMapper ckMapper;

    @Override
    public int getAgeCount(String age) {
        return userDataMapper.countAge(age);
    }

    @Override
    public int getAllCount() {
        return userDataMapper.countAll();
    }

    @Override
    public long getTagCount(String tagValue, String dt) {
        return ckMapper.selectTagCount(tagValue, dt);
    }

    /**
     * 统计用户某个字段某个值的数量
     * @param field 字段名
     * @param value 字段值
     * @return 数量
     */
    @Override
    public int getCount(String field, String value) {
        return userDataMapper.countByField(field, value);
    }
}
